package com.xpffly.design.single;

/**
 * @Author: xpengfei
 * @Date: 2021/3/28 0:01
 * @Description：单例模式场景类
 */
public class Scene {
    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            Singleton singleton = Singleton.getSingleton();
            singleton.doSomething();
            LazySingleton lazySingleton = LazySingleton.getLazySingleton();
            lazySingleton.doSomething();
        }
        Singleton singleton = Singleton.getSingleton();
        Singleton singleton1 = Singleton.getSingleton();
        System.out.println(singleton == singleton1);

        LazySingleton lazySingleton = LazySingleton.getLazySingleton();
        LazySingleton lazySingleton1 = LazySingleton.getLazySingleton();
        System.out.println(lazySingleton == lazySingleton1);
    }
}
